//////////////////////////////////////////////////////////////////////////////////
//
//	AvaMods Custom Weapon Loadout
//		- Version 1.0
//		- 04.03.2008
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
//   - British will have Colt .45's instead of the Webley
//   - The marksman class still gets webley
//   - Some other weapons switches.. Spades, etc...
//   - If you run 'dod_nadeforall' you must put this before it
//     if you give nades to any brit class besides marksman...
//
// Changelog:
//
//   - 02.23.2006 Version 0.1
//  	  Initial release
//  	  Marksman doesnt get a colt .45
//
//   - 03.05.2006 Version 0.2
//	  Added CVAR pointer
//	  A few minor changes
//
//   - 04.02.2006 Version 0.3
//	  Bug fix: invalid player errors
//
//   - 04.19.2006 Version 0.4
//	  Adjusted task time
//
//   - 04.19.2006 Version 0.5
//	  Now does the work of dod_nadeforall
//
//   - 07.06.2006 Version 0.6
//	  Replaced engine with fakemeta
//
//   - 01.15.2007 Version 0.6b
//	  Made CurWeapon register more specific
//	  Replaced ResetHud with dod_client_spawn
//	  Increased task time to 0.2
//
//   - 01.26.2007 Version 0.6c
//	  Reverted task time back to 0.1
//
//   - 01.28.2007 Version 0.7
//	  Changed some functions, got rid of un-needed code
//	  Removed tasks, now directly calls the function
//	  Replaced IF statements with switches
//
//   - 02.07.2007 Version 0.7b
//	  Fixed accidental removal of british sniper
//
//   - 07.10.2007 Version 0.8
//	  Fixed 'respawn' after round end not being hooked...
//	  Gave extra ammo to rocket classes
//
//   - 11.30.2007 Version 1.0
//	  Official Public Release
//
//   - 04.03.2008 Version 1.0 (re-release)
//	  Public CVAR
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <dodx>

new VERSION[] = "1.0"
new SVERSION[] = "v1.0 - by diamond-optic (www.AvaMods.com)"

public plugin_init()
{
	register_plugin("avamods weapons",VERSION,"diamond-optic")
	register_cvar("avamods_weapons_stats",SVERSION,FCVAR_SERVER|FCVAR_SPONLY)
		
	register_event("CurWeapon","check_weapon","be","1=1","2=1","2=2","2=3","2=19","2=37")
	
	register_event("ResetHUD","player_spawn","be")
}

public plugin_precache()
{
	precache_model("models/p_spade.mdl")
	precache_model("models/v_spade.mdl")
	precache_model("models/p_paraknife.mdl")
	precache_model("models/v_paraknife.mdl")
	precache_model("models/p_amerk.mdl")
	precache_model("models/v_amerk.mdl")
	precache_model("models/p_colt.mdl")
	precache_model("models/v_colt.mdl")
	precache_model("models/p_luger.mdl")
	precache_model("models/v_luger.mdl")
}

public player_spawn(id)
{	
	if (is_user_alive(id) && is_user_connected(id))	//dont bother if not using
		{
		if(get_user_team(id) == 1 && dod_get_map_info(MI_ALLIES_TEAM) == 1)	//allies & brits?
			//brit_task(id)
			set_task(0.1,"brit_task",id)		//set the task
		else if (get_user_team(id) == 1)
			//allies_task(id)
			set_task(0.1,"allies_task",id)		//set the task
		else if (get_user_team(id) == 2)
			//para_task(id)
			set_task(0.1,"axis_task",id)		//set the task

		}
}

public check_weapon(id)
{
	if(is_user_alive(id) && is_user_connected(id)) 
		{
		new team = get_user_team(id)
		new ammo,clip,zGun = dod_get_user_weapon(id,clip,ammo)
		
		switch(team)
			{
			case 1: {
				if(zGun == DODW_SPADE)
					{
					set_pev(id,pev_viewmodel2,"models/v_spade.mdl")
					set_pev(id,pev_weaponmodel2,"models/p_spade.mdl")
					}
				else if (zGun == DODW_GERKNIFE)
					{
					set_pev(id,pev_viewmodel2,"models/v_paraknife.mdl")
					set_pev(id,pev_weaponmodel2,"models/p_paraknife.mdl")
					}
				}
			case 2: {
				if (zGun == DODW_AMERKNIFE)
					{
					set_pev(id,pev_viewmodel2,"models/v_amerk.mdl")
					set_pev(id,pev_weaponmodel2,"models/p_amerk.mdl")
					}
				else if (zGun == DODW_COLT)
					{
					set_pev(id,pev_viewmodel2,"models/v_colt.mdl")
					set_pev(id,pev_weaponmodel2,"models/p_colt.mdl")
					}
				}
			}
		}
}

public brit_task(id)
{
	if(is_user_alive(id) && is_user_connected(id)) 
		{
		new brit_class = dod_get_user_class(id)		//get their class
		
		switch(brit_class)
			{
			case DODC_ENFIELD: {
					strip_user_weapons(id)		//take away the defualt weapons 
					give_item(id,"weapon_enfield")
					give_item(id,"ammo_enfield")
					give_item(id,"weapon_colt")
					give_item(id,"ammo_colt")
					give_item(id,"weapon_amerknife")
					give_item(id,"weapon_handgrenade")
					give_item(id,"weapon_handgrenade")
					}
			case DODC_STEN: {
					strip_user_weapons(id)			//take away the defualt weapons 
					give_item(id,"weapon_sten")
					give_item(id,"ammo_sten")
					give_item(id,"weapon_colt")
					give_item(id,"ammo_colt")
					give_item(id,"weapon_gerknife")
					give_item(id,"weapon_handgrenade")
					}
			case DODC_BREN: {
					strip_user_weapons(id)			//take away the defualt weapons 
					give_item(id,"weapon_bren")
					give_item(id,"ammo_bren")
					give_item(id,"weapon_luger")
					give_item(id,"ammo_luger")
					give_item(id,"weapon_amerknife")
					give_item(id,"weapon_handgrenade")
					}
			case DODC_PIAT: {
					strip_user_weapons(id)			//take away the defualt weapons 
					give_item(id,"weapon_piat")
					give_item(id,"ammo_piat")
					give_item(id,"ammo_piat")
					give_item(id,"ammo_piat")
					give_item(id,"weapon_colt")
					give_item(id,"ammo_colt")
					give_item(id,"weapon_spade")
					give_item(id,"weapon_handgrenade")	//no longer need to run nadeforall
					}
			case DODC_MARKSMAN: give_item(id,"weapon_handgrenade")	//no longer need to run nadeforall
			}
		}		
}

public axis_task(id)
{
	if(is_user_alive(id) && is_user_connected(id)) 
		{
		new axis_class = dod_get_user_class(id)		//get their class
	
		switch(axis_class)
			{
			case DODC_PANZERJAGER: {
					strip_user_weapons(id)	
					give_item(id,"weapon_pschreck")
					give_item(id,"ammo_pschreck")
					give_item(id,"ammo_pschreck")
					give_item(id,"ammo_pschreck")
					give_item(id,"weapon_luger")
					give_item(id,"ammo_luger")
					give_item(id,"weapon_spade")
					give_item(id,"weapon_stickgrenade")	//no longer need to run nadeforall
					}
			case DODC_MP40: {
					strip_user_weapons(id)	
					give_item(id,"weapon_mp40")
					//give_item(id,"ammo_mp40")
					give_item(id,"weapon_luger")
					give_item(id,"ammo_luger")
					give_item(id,"weapon_spade")
					give_item(id,"weapon_stickgrenade")
					}
			case DODC_K43: {
					strip_user_weapons(id)
					give_item(id,"weapon_k43")
					give_item(id,"ammo_k43")
					give_item(id,"weapon_colt")
					give_item(id,"ammo_colt")
					give_item(id,"weapon_amerknife")
					give_item(id,"weapon_stickgrenade")
					give_item(id,"weapon_stickgrenade")
					}
			case DODC_MG34: give_item(id,"weapon_stickgrenade")	//no longer need to run nadeforall
			case DODC_MG42: give_item(id,"weapon_stickgrenade")	//no longer need to run nadeforall
			case DODC_SCHARFSCHUTZE: give_item(id,"weapon_stickgrenade")	//no longer need to run nadeforall
			}
		}
}

public allies_task(id)
{
	if(is_user_alive(id) && is_user_connected(id)) 
		{
		new allies_class = dod_get_user_class(id)		//get their class
	
		switch(allies_class)
			{
			case DODC_CARBINE: {
					strip_user_weapons(id)	
					give_item(id,"weapon_m1carbine")
					give_item(id,"ammo_m1carbine")
					give_item(id,"weapon_colt")
					give_item(id,"ammo_colt")
					give_item(id,"weapon_gerknife")
					give_item(id,"weapon_handgrenade")
					give_item(id,"weapon_handgrenade")
					}
			case DODC_SNIPER: {
					strip_user_weapons(id)	
					give_item(id,"weapon_spring")
					give_item(id,"ammo_spring")
					give_item(id,"weapon_luger")
					give_item(id,"ammo_luger")
					give_item(id,"weapon_spade")
					give_item(id,"weapon_handgrenade")	//no longer need to run nadeforall
					}
			case DODC_BAZOOKA: {
					strip_user_weapons(id)
					give_item(id,"weapon_bazooka")
					give_item(id,"ammo_bazooka")
					give_item(id,"ammo_bazooka")
					give_item(id,"ammo_bazooka")
					give_item(id,"weapon_luger")
					give_item(id,"ammo_luger")
					give_item(id,"weapon_spade")
					give_item(id,"weapon_handgrenade")	//no longer need to run nadeforall
					}
			case DODC_30CAL: give_item(id,"weapon_handgrenade")	//no longer need to run nadeforall
			}
		}
}